package com.bian.starter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author bianpengfei
 * @create 2019-02-03 16:46
 **/

@Configuration
@ConditionalOnWebApplication   //如果是web项目才生效
@EnableConfigurationProperties(HelloProperties.class)
public class HelloServiceAutoConfiguration {

    @Autowired
    private HelloProperties helloProperties;

    @Bean
    public HelloService helloService() {
        HelloService service =  new HelloService();
        service.setHelloProperties(helloProperties);
        return service;
    }

}
